package cn.lut.springboot.service.impl;

import cn.lut.springboot.entity.Student;
import cn.lut.springboot.mapper.StudentMapper;
import cn.lut.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @user:dell
 * @date:2021年01月01 21:27
 */
@Service
public class StudentServiceImpl  implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public Student queryStudentById(Integer id) {

        return  studentMapper.selectByPrimaryKey(id);
    }
    @Transactional
    @Override
    public int updateStudentById(Student student) {
//        修改成功
        int i = studentMapper.updateByPrimaryKeySelective(student);
//        修改失败
//        int a=10/0;
        return i;
    }
}
